<template>
	<view class="page friend_Page">
		<headerinfo></headerinfo>
		<u-navbar title="预览" :placeholder="true" :autoBack="true"></u-navbar>
		<view class="changeMy">
			<image :src="url" mode="widthFix" style="width: 100%;"></image>
		</view>
		<view class="btn" @click="sureChange()">
			确认更换
		</view>
	</view>
</template>

<script>
	import minxins from '../../common/upload.js';
	export default {
		mixins: [minxins],
		components: {},
		data() {
			return {
				url: '',
				form:{}
			};
		},
		onLoad(e) {
			this.getData()
			this.url = e.url
		},
		methods: {
			getData() {
				this.$api.myInfo().then(res => {
					this.form = res
				})
			},
			sureChange(){
				this.form.background = this.url
				
				this.$api2.updateUserInfo(this.form).then(res=>{
					this.$Show.show('设置成功')
					setTimeout(()=>{
						uni.redirectTo({
							url:'/pagesfriend/tabbar/mine'
						})
					},1500)
				})
			}
		}
	};
</script>


<style lang="scss" scoped>
	.page {
		background-color: #fff;
	}

	.changeMy {
		border-top: 1px solid #f8f8f8;
	}
	.btn{
		width: 600rpx;
		height: 90rpx;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #de4849;
		color: #fff;
		margin: 0 auto;
		margin-top: 30rpx;
	}
</style>